package com.example.f_code.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.example.f_code.WelcomeActivity;

public class PrefsUtil {
    private static final String PREFS_NAME = "app_prefs"; // 文件名
    private static final String KEY_FIRST_LAUNCH = "is_first_launch"; // 存储key

    /*
    * 检查是否首次启动
    * */
    public static boolean isFirstLaunch(Context context) {
        SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
        return prefs.getBoolean(KEY_FIRST_LAUNCH, true);
    }

    /*
    * 标记启动
    * */
    public static void setLaunched(Context context) {
        SharedPreferences.Editor editor = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit();
        editor.putBoolean(KEY_FIRST_LAUNCH, false);
        editor.apply();
    }
}
